package com.qidian.mes.device.service.impl;

import com.qidian.common.pojo.MESResult;
import com.qidian.mes.device.mapper.LedgerMapper;
import com.qidian.mes.device.service.LedgerService;
import com.qidian.mes.pojo.Ledger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @Author 刘泽磊
 * @Company 起点编程
 * @Description
 * @Time 2024/10/17 19:02
 */
@Service
public class LedgerServiceImpl implements LedgerService {
    @Autowired
    private LedgerMapper ledgerMapper;
    @Override
    public MESResult select(Ledger ledger) {
        return MESResult.success(ledgerMapper.select(ledger));
    }

    @Override
    public MESResult insert(Ledger ledger) {
        ledger.setCreateTime(new Date());
        ledger.setLedgerScms(0);
        ledger.setScmsId((long) 0);
        return MESResult.success(ledgerMapper.insert(ledger));
    }

    @Override
    public MESResult update(Ledger ledger) {
        return MESResult.success(ledgerMapper.update(ledger));
    }

    @Override
    public MESResult updateScms(Ledger ledger) {
        return MESResult.success(ledgerMapper.updateScms(ledger));
    }

    @Override
    public MESResult selectById(Long ledgerId) {
        return MESResult.success(ledgerMapper.selectById(ledgerId));
    }

    @Override
    public MESResult delete(Long ledgerId) {
        return MESResult.success(ledgerMapper.delete(ledgerId));
    }
}
